﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

namespace WebApplication1
{
    public class Dbhelper
    {
        private static readonly string conString = "server =. ;database = CMS ;Uid =sa ; Pwd =123456";

        //根据sql语句查询表
        public static DataTable table (string sql)
        {
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql,conString );
            DataTable dataTable = new DataTable();
            dataAdapter.Fill(dataTable);
            return dataTable;

        }

        //查询受影响的行数
        public static int AddOrUpdateOrDelete(string sql)
        {
            SqlConnection connection = new SqlConnection(conString );
            SqlCommand sqlCommand = new SqlCommand(sql, connection);
            connection.Open();
            var abc = sqlCommand.ExecuteNonQuery();
            return abc;

        }


    }
}